package com.example.springboot_demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.springboot_demo.entity.Goods;
import com.example.springboot_demo.mapper.GoodsMapper;
import com.example.springboot_demo.service.GoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description:
 * <P> Date: 2024/9/3:16:53
 */

@SuppressWarnings({"unchecked", ""})
@RestController
@RequestMapping("goods")
public class GoodsController {
    private static final Logger log = LoggerFactory.getLogger(GoodsController.class);


    @Autowired
    private GoodsService goodsService;


    /**
     * 根据id 精准查询 名称和作者模糊查询
     * 文档地址：https://doc.apipost.net/docs/detail/320a3179e064000?target_id=321eef0de469000
    */
    @GetMapping("/findGoods")
    public Object findGoods(Integer id,String author,String name){
        List<Goods> goods = goodsService.findGoods(id, author, name);
        return goods;
    }

    /**
     * addGoods
    */

    @PostMapping("/addGoods")
    public String addGoods(@RequestBody Goods goods){
        boolean save = goodsService.save(goods);
        return "新增成功";
    }

}
